package com.duobaoyu.dby.supply.admin.controller.tool;

import com.duobaoyu.dby.common.core.util.R;
import com.duobaoyu.dby.common.security.annotation.Inner;
import com.duobaoyu.dby.supply.admin.service.AdminChannelToolBizService;
import com.duobaoyu.dby.supply.common.biz.dto.tool.ChannelToolAfterSaleAttributeDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * 渠道工具
 * @author chenms
 * @date 2023/11/25 11:02 AM
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/tool/channel")
public class ChannelToolController {

    private final AdminChannelToolBizService adminChannelToolBizService;

    /**
     * 查询渠道订单
     * @param orderSn 供应链订单号
     */
    @GetMapping("order/info")
    public R<Object> getChannelOrderInfo(@NotBlank(message = "供应链订单号不能为空") String orderSn) {
        return R.ok(adminChannelToolBizService.getChannelOrderInfo(orderSn));
    }

    /**
     * 查询渠道出库单
     * @param orderSn 供应链订单号
     */
    @GetMapping("order/outbound")
    public R<Object> getChannelOutboundOrder(@NotBlank(message = "供应链订单号不能为空") String orderSn) {
        return R.ok(adminChannelToolBizService.getChannelOutboundOrder(orderSn));
    }

    /**
     * 查询渠道售后详情
     * @param afterSaleSn 售后单号
     */
    @GetMapping("after-sale/detail")
    public R<Object> getChannelAfterSaleDetail(@NotBlank(message = "售后单号不能为空") String afterSaleSn) {
        return R.ok(adminChannelToolBizService.getChannelAfterSaleDetail(afterSaleSn));
    }

    /**
     * 查询渠道售后权益
     */
    @PostMapping("after-sale/attributes")
   public R<Object> getChannelAfterSaleAttributes(@Valid @RequestBody ChannelToolAfterSaleAttributeDTO channelToolAfterSaleAttributeDTO) {
       return R.ok(adminChannelToolBizService.getChannelAfterSaleAttributes(channelToolAfterSaleAttributeDTO));
   }

    /**
     * 查询渠道商品详情
     * @param skuCode 供应链sku编码
     */
    @GetMapping("product/detail")
    public R<Object> getChannelProductSkuDetail(@NotBlank(message = "供应链sku编码不能为空") String skuCode) {
        return R.ok(adminChannelToolBizService.getChannelProductSkuDetail(skuCode));
    }

}
